﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CardLogistics.Web.Components;
using System.Data;

namespace CardLogistics.Web.MainPage.Purchase.Demand
{
    public partial class Detail : BasePage
    {
        private static readonly CardLogistics.DAL.Purchase.Purchase_DemandData DAL = new CardLogistics.DAL.Purchase.Purchase_DemandData();
        private static readonly CardLogistics.DAL.Purchase.Purchase_DetailedData DDAL = new CardLogistics.DAL.Purchase.Purchase_DetailedData();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitControl();
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public void InitControl()
        {
            string _key = Request.QueryString["id"];
            WebUserControl_AppInfo1.InfoID = _key;
            WebUserControl_AppInfo1.UserID = LoggedUser.ID;
            if (!string.IsNullOrEmpty(_key))
            {
                CardLogistics.Model.Purchase.Purchase_Demand pData = DAL.GetModel(_key);
                SetWebControls(this.Page, pData);
                DataTable dt = DDAL.GetInfoByDemandId(pData.ID);
                string detName = ""; 
                if (dt != null && dt.Rows.Count > 0)
                {
                    //foreach (DataRow dr in dt.Rows)
                    //{
                    //    detName += dr["cardtypename"].ToString() + "[" + dr["CARDNUMBER"].ToString() + "];";
                    //}
                    //PConNo.Text = detName.TrimEnd(';') + "  总数量:" + Convert.ToInt32(dt.Compute("sum(CARDNUMBER)", ""));//赠品数量;

                    rptDetailList.DataSource = dt;
                    rptDetailList.DataBind();
                }
            }
        }
    }
}